package com.sen.rbac.feign.fallback;

import com.sen.common.common.response.MessageResult;
import com.sen.rbac.feign.RbacResourceFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import static com.sen.common.common.response.ResultMsgEnum.SERVICE_EXCEPTION;


/**
 * @author esjiang
 */
@Slf4j
@Component
public class RbacResourceFeignFallbackFactory implements FallbackFactory<RbacResourceFeign> {
    @Override
    public RbacResourceFeign create(Throwable throwable) {
        log.error(SERVICE_EXCEPTION.getMsg(),throwable);
        return (s) ->  MessageResult.reqFailed(SERVICE_EXCEPTION);
    }

}
